/*********************************************************************************************************
**
**                                   GJB 标准测试集
**
**                               Copyright All Rights Reserved
**
**--------------文件信息--------------------------------------------------------------------------------
**
** 文   件   名: gjb_S0100901GN_4.c
**
** 文件创建日期: 2021 年 1 月 22 日
**
** 描        述: 初始化、销毁条件变量功能测试
*********************************************************************************************************/
#include <pthread.h>
#include <stdio.h>

//#include "gjb.h"

pthread_cond_t  cond1_cv_9014, cond2_cv_9014;
pthread_cond_t  cond3_cv_9014 = PTHREAD_COND_INITIALIZER;

int gjb_S0100901GN_4(int argc, char **argv)
{
    int                rc;
    pthread_condattr_t condattr;


    /*
     *  Initialize a condition variable attribute object
     */
    if((rc=pthread_condattr_init(&condattr)) != 0) {
        printf("Error at pthread_condattr_init(), rc=%d\n",rc);
        goto __errno_handle;
    }

    /*
     *  Initialize cond1 with the default condition variable attribute
     */
    if((rc=pthread_cond_init(&cond1_cv_9014,&condattr)) != 0) {
        printf("Fail to initialize cond1, rc=%d\n",rc);
        goto __errno_handle;
    }

    /*
     *  Initialize cond2 with NULL attributes
     */
    if((rc=pthread_cond_init(&cond2_cv_9014,NULL)) != 0) {
        printf("Fail to initialize cond2, rc=%d\n",rc);
        goto __errno_handle;
    }

    /*
     *  Destroy the condition variable attribute object
     */
    if((rc=pthread_condattr_destroy(&condattr)) != 0) {
        printf("Error at pthread_condattr_destroy(), rc=%d\n",rc);
        goto __errno_handle;
    }

    /*
     *  Destroy cond1
     */
    if((rc=pthread_cond_destroy(&cond1_cv_9014)) != 0) {
        printf("Fail to destroy cond1, rc=%d\n",rc);
        printf("Test FAILED\n");
        goto __errno_handle;
    }

    /*
     *  Destroy cond2
     */
    if((rc=pthread_cond_destroy(&cond2_cv_9014)) != 0) {
        printf("Fail to destroy cond2, rc=%d\n",rc);
        printf("Test FAILED\n");
        goto __errno_handle;
    }

    /*
     *  Destroy cond3
     */
    if((rc=pthread_cond_destroy(&cond3_cv_9014)) != 0) {
        printf("Fail to destroy cond3, rc=%d\n",rc);
        printf("Test FAILED\n");
        goto __errno_handle;
    }

    printf("<RSLT>..................................................[(0)]\n \n \n");

    return  (0);

__errno_handle:
    printf("<RSLT>..................................................[(-1)]\n \n \n");
    return  (-1);
}




